package cn.ex.ymcc.feign.fallback;



import cn.ex.ymcc.doc.CourseDoc;
import cn.ex.ymcc.feign.ESCourseFeignClient;
import cn.ex.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ESCourseFeignClientFallbackFactory implements FallbackFactory<ESCourseFeignClient> {

    @Override
    public ESCourseFeignClient create(Throwable throwable) {
        return new ESCourseFeignClient() {
            @Override
            public JSONResult onLineCourse(CourseDoc doc) {
                return JSONResult.error("搜索服务不可达，熔断降级！！");
            }

            @Override
            public JSONResult offLineCourse(Long courseId) {
                return JSONResult.error("搜索服务不可达，熔断降级！！");
            }
        };
    }
}
